// import HomeView from "@/views/HomeView.vue";
// import NotFoundView from "@/views/NotFoundView.vue";
// import SearchView from "@/views/SearchView.vue";
import { createRouter, createWebHashHistory, createWebHistory } from "vue-router";

// 创建路由实例
const router = createRouter({
  history: createWebHistory(), // History路由模
  // history: createWebHashHistory(), // hash(哈希)路由模式，地址栏上 #/ 表示
  routes: [
    {path: "/find",component: ()=> import("@/views/FindView.vue")},
    {path: "/friend",component: ()=> import("@/views/Friend.vue")},
    {path: "/my",component: ()=> import("@/views/MyView.vue")},
    {path: "/home",component: ()=> import("@/views/HomeView.vue")},
    // 动态路由参数 可选避免白屏
    {name:"SearchView",path: "/search/:keyword?",component: ()=> import("@/views/SearchView.vue")},
    // redirect 重定向 避免首页白屏
    {path: "/",redirect: "/home"},
    // 404 错误 里面路径不存在白屏
    {path: "/:pathMatch(.*)*",component: ()=> import("@/views/NotFoundView.vue")}

  ], // 路由配置表
});

1
// 导出了路由实例
export default router;
